﻿@model BrnMall.Web.MallAdmin.Models.CouponTypeModel

@section header{
    <title>添加优惠劵类型</title>
    <link type="text/css" rel="stylesheet" href="/admin_mall/content/css/site.css"/>
    <script type="text/javascript" src="/admin_mall/scripts/jquery.js"></script>
    <script type="text/javascript" src="/admin_mall/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin_mall/scripts/jquery.validate.unobtrusive.js"></script>
    <link href="/admin_mall/content/jbox/Skins/Default/jbox.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/admin_mall/content/jbox/jquery.jBox-2.3.min.js"></script>
    <script type="text/javascript" src="/admin_mall/content/my97datepicker/WdatePicker.js"></script>
    <script type="text/javascript" src="/admin_mall/scripts/selectlist.js"></script>
    <script type="text/javascript">
        //重写店铺弹出层中的SetSelectedStore方法
        function SetSelectedStore(item) {
            var selectedStoreId = $(item).attr("storeid");
            var storeObj = $(openStoreSelectLayerBut).parent().find(".StoreId");
            storeObj.val(selectedStoreId);
            var getstoreName = $(item).text();
            $(openStoreSelectLayerBut).val(getstoreName);
            $(openStoreSelectLayerBut).parent().find(".StoreName").val(getstoreName);
            $.jBox.close('StoreSelectLayer');
            $("#StoreCid").html("").attr("disabled", "disabled");
            $.get("/malladmin/store/storeclassselectlist?storeId=" + selectedStoreId + "&time=" + new Date(), function (data) {
                var result = eval("(" + data + ")");
                var list = "";
                list += "<option value='-1' slected='selected'>无限制</option>";
                for (var i = 0; i < result.length; i++) {
                    list = list + "<option value='" + result[i].storecid + "'>" + result[i].name + "</option>";
                }
                $("#StoreCid").html(list).attr("disabled", "");
            });
        }

        $(function () {

            if (parseInt($("input[name=SendModel]").val()) != 0) {
                $("#GetModel").parents("tr").hide();
                $("#SendStartTime").parents("tr").hide();
            }
            else {
                $("#GetModel").parents("tr").show();
                $("#SendStartTime").parents("tr").show();
            }

            if (parseInt($("input[name=UseTimeType]").val()) == 0) {
                $("#UseExpireTime").parents("tr").hide();
                $("#UseStartTime").parents("tr").show();
            }
            else {
                $("#UseExpireTime").parents("tr").show();
                $("#UseStartTime").parents("tr").hide();
            }

            $("input[name=SendModel]").click(function () {
                if (parseInt($(this).val()) != 0) {
                    $("#GetModel").parents("tr").hide();
                    $("#SendStartTime").parents("tr").hide();
                }
                else {
                    $("#GetModel").parents("tr").show();
                    $("#SendStartTime").parents("tr").show();
                }
            })

            $("input[name=UseTimeType]").click(function () {
                if ($(this).val() == "0") {
                    $("#UseExpireTime").parents("tr").hide();
                    $("#UseStartTime").parents("tr").show();
                }
                else {
                    $("#UseExpireTime").parents("tr").show();
                    $("#UseStartTime").parents("tr").hide();
                }
            })

            //初始化店铺分类选择框
            if ($("#StoreId").val() > 0) {
                $("#StoreCid").html("").attr("disabled", "disabled");
                $.get("/malladmin/store/storeclassselectlist?storeId=" + $("#StoreId").val() + "&time=" + new Date(), function (data) {
                    var result = eval("(" + data + ")");
                    var list = "";
                    list += "<option value='-1' slected='selected'>无限制</option>";
                    for (var i = 0; i < result.length; i++) {
                        list = list + "<option value='" + result[i].storecid + "'>" + result[i].name + "</option>";
                    }
                    $("#StoreCid").html(list).attr("disabled", "");
                    $("#StoreCid").find("option[value=" + $("#hiddenStoreCid").val() + "]").attr("selected", true);
                });
            }

        })

    </script>
}

@section body{
<h1 class="rightH1">
优惠劵管理 &gt;&gt; 添加类型
<div class="right">
<a href="@Html.Raw(ViewData["referer"].ToString())" class="menuBT"><img src="/admin_mall/content/images/goback.jpg"/>返回列表</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</h1>

<div class="addTable">
@using (Html.BeginForm())
{
<table width="100%">
          <tr>
    <td width="106px" align="right">店铺名称：</td>
    <td>
        <div class="selectBt">
            <input type="button" value="@Model.StoreName" onclick="openStoreSelectLayer(this)" />
            <input type="hidden" class="StoreId" id="StoreId" name="StoreId" value="@Model.StoreId" />
            <input type="hidden" class="StoreName" id="StoreName" name="StoreName" value="@Model.StoreName" />
        </div>
    @Html.ValidationMessageFor(x => x.StoreId)</td>
    </tr>
  <tr>
    <td align="right">优惠劵名称：</td>
    <td>@Html.TextBoxFor(x => x.CouponTypeName, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.CouponTypeName)</td>
    </tr>
          <tr>
    <td align="right">优惠劵金额：</td>
    <td>@Html.TextBoxFor(x => x.Money, new { @class = "input", size = "3" })元 @Html.ValidationMessageFor(x => x.Money)</td>
    </tr>
              <tr>
    <td align="right">优惠劵数量：</td>
    <td>@Html.TextBoxFor(x => x.Count, new { @class = "input", size = "3" })@Html.ValidationMessageFor(x => x.Count)</td>
    </tr>
                  <tr>
    <td align="right">发放方式：</td>
    <td><p>
      <label>@Html.RadioButtonFor(x => x.SendModel, 0, new { @class = "checkbox" })免费领取</label>
      <label>@Html.RadioButtonFor(x => x.SendModel, 1, new { @class = "checkbox" })手动发放</label>
      <label>@Html.RadioButtonFor(x => x.SendModel, 2, new { @class = "checkbox" })随活动发放</label>
      <br />
    </p></td>
    </tr>
                  <tr>
    <td align="right">领取方式：</td>
    <td><p>
      <label>@Html.RadioButtonFor(x => x.GetModel, 0, new { @class = "checkbox" })无限制</label>
      <label>@Html.RadioButtonFor(x => x.GetModel, 1, new { @class = "checkbox" })限领一张</label>
      <label>@Html.RadioButtonFor(x => x.GetModel, 2, new { @class = "checkbox" })每天限领一张</label>
      <br />
    </p></td>
    </tr>
                  <tr>
    <td align="right">使用方式：</td>
    <td><p>
      <label>@Html.RadioButtonFor(x => x.UseModel, 0, new { @class = "checkbox" }) 可以叠加</label>
      <label>@Html.RadioButtonFor(x => x.UseModel, 1, new { @class = "checkbox" }) 不可以叠加</label>
      <br />
    </p></td>
    </tr>

          <tr>
    <td align="right">最小用户等级：</td>
    <td>@Html.DropDownListFor(x => x.UserRankLower, ViewData["userRankList"] as List<SelectListItem>) @Html.ValidationMessageFor(x => x.UserRankLower)</td>
    </tr>

              <tr>
    <td align="right">最小订单金额：</td>
    <td>@Html.TextBoxFor(x => x.OrderAmountLower, new { @class = "input", size = "3" })元 @Html.ValidationMessageFor(x => x.OrderAmountLower)</td>
    </tr>
    <tr>
        <td width="76px;" align="right">
            限制分类：
        </td>
        <td>
            <select id="StoreCid" name="LimitStoreCid" disabled="disabled">
            <option value="-1" selected="selected">无限制</option>
            </select>
            <input type="hidden" value="@Model.LimitStoreCid" id="hiddenStoreCid"/>
            @Html.ValidationMessageFor(x => x.LimitStoreCid)
        </td>
    </tr>

    <tr>
    <td align="right">限制商品：</td>
        <td><p>
        <label>@Html.RadioButtonFor(x => x.LimitProduct, 0, new { @class = "checkbox" })否</label>
        <label>@Html.RadioButtonFor(x => x.LimitProduct, 1, new { @class = "checkbox" })是</label>
        <br />
    </p></td>
    </tr>
            <tr>
        <td align="right">
            发放时间：
        </td>
        <td>
            @Html.TextBoxFor(x => x.SendStartTime, new { @class = "input", size = "18", onfocus = "WdatePicker({el:'SendStartTime'})" })
            至
            @Html.TextBoxFor(x => x.SendEndTime, new { @class = "input", size = "18", onfocus = "WdatePicker({el:'SendEndTime'})" })
            @Html.ValidationMessageFor(x => x.SendStartTime)
            @Html.ValidationMessageFor(x => x.SendEndTime)
        </td>
    </tr>
    <tr>
    <td align="right">使用时间类型：</td>
        <td><p>
        <label>@Html.RadioButtonFor(x => x.UseTimeType, 0, new { @class = "checkbox" })绝对时间</label>
        <label>@Html.RadioButtonFor(x => x.UseTimeType, 1, new { @class = "checkbox" })相对时间</label>
        <br />
    </p></td>
    </tr>
     <tr>
    <td align="right">使用过期时间：</td>
        <td>@Html.TextBoxFor(x => x.UseExpireTime, new { @class = "input", size = "3" })天</td>
    </tr>
    <tr>
        <td align="right">
            使用时间段：
        </td>
        <td>
            @Html.TextBoxFor(x => x.UseStartTime, new { @class = "input", size = "18", onfocus = "WdatePicker({el:'UseStartTime'})" })
            至
            @Html.TextBoxFor(x => x.UseEndTime, new { @class = "input", size = "18", onfocus = "WdatePicker({el:'UseEndTime'})" })
            @Html.ValidationMessageFor(x => x.UseStartTime)
            @Html.ValidationMessageFor(x => x.UseEndTime)
        </td>
    </tr>

  <tr>
    <td align="right">&nbsp;</td>
    <td>
    <a href="" class="addBt" id="sumbitBut" ><img src="/admin_mall/content/images/submit.jpg" /></a>
            <script type="text/javascript">
                $(function () {
                    $("#sumbitBut").click(function () {
                        $("form:first").submit();
                        return false;
                    })
                });
        </script>
    </td>
    </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
</table>
}
</div>
}